package com.project.servlet;

import com.project.bean.UserBean;
import com.project.service.imp.userServiceImp;
import com.project.service.userService;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class TestServlet extends HttpServlet {
    private userService service = new userServiceImp();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //        设置请求信息的编码集，只对post有效
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String userName = req.getParameter("userName");
        String pwd = req.getParameter("passWord");
        UserBean bean = service.login(userName, pwd);
        if (bean == null) {
            resp.getWriter().print("登陆失败");
        } else {
            resp.getWriter().print("登陆成功");
        }

    }
}

